package com.example.healkep.fragment.bg;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

import com.example.healkep.echarts.EchartOptionUtil;
import com.example.healkep.echarts.EchartView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.example.healkep.R;

public class FragmentMonth extends Fragment {

    private double[] bb = new double[30];
    private double[] ab1 = new double[30];
    private double[] ab2 = new double[30];
    private double[] bl = new double[30];
    private double[] al1 = new double[30];
    private double[] al2 = new double[30];
    private double[] bd = new double[30];
    private double[] ad1 = new double[30];
    private double[] ad2 = new double[30];
    private double[] bs = new double[30];

    ArrayList<String> time = new ArrayList<>();
    private EchartView lineChart1,lineChart2,lineChart3,lineChart4,lineChart5,lineChart6,lineChart7,lineChart8,lineChart9,lineChart10,barChart,pieChart;
    private ScrollView mScrollView;
    private TextView textView1, textView2, textView3;

    private double bb_ave, ab1_ave, ab2_ave, bl_ave, al1_ave, al2_ave, bd_ave, ad1_ave, ad2_ave, bs_ave;
    private double bg_max = 0, bg_min = 0;
    private int bb_count = 0, ab1_count = 0, ab2_count=0, bl_count = 0, al1_count = 0, al2_count=0, bd_count = 0, ad1_count = 0, ad2_count=0, bs_count=0;
    private double bb_sum = 0, ab1_sum = 0, ab2_sum=0, bl_sum = 0, al1_sum = 0, al2_sum=0, bd_sum = 0, ad1_sum = 0, ad2_sum=0, bs_sum=0;
    private int sum;  //记录七日测量总数
    private double bg_sum,bg_ave=0; // 配合sum计算总平均值
    private int count_high = 0, count_low = 0, count_ave = 0;  //记录偏高血糖值（餐前大于6.1，餐后大于7.8）/偏低血糖值（小于3.9）/正常血糖值

    @Override
    public View onCreateView(final LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {

        final Intent intent = getActivity().getIntent();
        time = intent.getStringArrayListExtra("time_month");

        bb = intent.getDoubleArrayExtra("bb_month");
        ab1 = intent.getDoubleArrayExtra("ab1_month");
        ab2 = intent.getDoubleArrayExtra("ab2_month");
        bl = intent.getDoubleArrayExtra("bl_month");
        al1 = intent.getDoubleArrayExtra("al1_month");
        al2 = intent.getDoubleArrayExtra("al2_month");
        bd = intent.getDoubleArrayExtra("bd_month");
        ad1 = intent.getDoubleArrayExtra("ad1_month");
        ad2 = intent.getDoubleArrayExtra("ad2_month");
        bs = intent.getDoubleArrayExtra("bs_month");

        bg_max = bb[0];
        for(int i=0 ;i<30; i++){
            if(bb[i] != 0) {bg_min = bb[i]; break;}
            if(ab1[i] != 0) {bg_min = ab1[i]; break;}
            if(ab2[i] != 0) {bg_min = ab2[i]; break;}
            if(bl[i] != 0) {bg_min = bl[i]; break;}
            if(al1[i] != 0) {bg_min = al1[i]; break;}
            if(al2[i] != 0) {bg_min = al2[i]; break;}
            if(bd[i] != 0) {bg_min = bd[i]; break;}
            if(ad1[i] != 0) {bg_min = ad1[i]; break;}
            if(ad2[i] != 0) {bg_min = ad2[i]; break;}
            if(bs[i] != 0) {bg_min = bs[i]; break;}
        }  //从所有数据中选择最小值作为bg_min的初始值

        for(int i=0;i<30;i++){
            if(bb[i]!=0){
                bb_count++; bb_sum += bb[i]; sum++; bg_sum += bb[i];
                if(bb[i] < 4.4) count_low++;
                else if(bb[i] > 6.1) count_high++;
                else count_ave++;
            }
            if(bb[i] > bg_max) bg_max = bb[i];
            if(bb[i] < bg_min && bb[i]!= 0) bg_min = bb[i];
        }
        bb_ave = bb_sum/bb_count;
        bb_ave = (double)Math.round(bb_ave*100)/100;   //保留两位小数

        for(int i=0;i<30;i++){
            if(ab1[i]!=0){
                ab1_count++; ab1_sum += ab1[i]; sum++; bg_sum += ab1[i];
                if(ab1[i] < 6.7) count_low++;
                else if(ab1[i] > 8.3) count_high++;
                else count_ave++;
            }
            if(ab1[i] > bg_max) bg_max = ab1[i];
            if(ab1[i] < bg_min && ab1[i] != 0) bg_min = ab1[i];
        }
        ab1_ave = ab1_sum/ab1_count;
        ab1_ave = (double)Math.round(ab1_ave*100)/100;

        for(int i=0;i<30;i++){
            if(ab2[i]!=0){
                ab2_count++; ab2_sum += ab2[i]; sum++; bg_sum += ab2[i];
                if(ab2[i] < 5.0) count_low++;
                else if(ab2[i] > 7.2) count_high++;
                else count_ave++;
            }
            if(ab2[i] > bg_max) bg_max = ab2[i];
            if(ab2[i] < bg_min && ab2[i] != 0) bg_min = ab2[i];
        }
        ab2_ave = ab2_sum/ab2_count;
        ab2_ave = (double)Math.round(ab2_ave*100)/100;

        for(int i=0;i<30;i++){
            if(bl[i]!=0){
                bl_count++; bl_sum += bl[i]; sum++; bg_sum += bl[i];
                if(bl[i] < 4.4) count_low++;
                else if(bl[i] > 6.1) count_high++;
                else count_ave++;
            }
            if(bl[i] > bg_max) bg_max =bl[i];
            if(bl[i] < bg_min && bl[i] != 0) bg_min = bl[i];
        }
        bl_ave = bl_sum/bl_count;
        bl_ave = (double)Math.round(bl_ave*100)/100;

        for(int i=0;i<30;i++){
            if(al1[i]!=0){
                al1_count++; al1_sum += al1[i]; sum++; bg_sum += al1[i];
                if(al1[i] < 6.7) count_low++;
                else if(al1[i] > 8.3) count_high++;
                else count_ave++;
            }
            if(al1[i] > bg_max) bg_max =al1[i];
            if(al1[i] < bg_min && al1[i] != 0) bg_min = al1[i];
        }
        al1_ave = al1_sum/al1_count;
        al1_ave = (double)Math.round(al1_ave*100)/100;

        for(int i=0;i<30;i++){
            if(al2[i]!=0){
                al2_count++; al2_sum += al2[i]; sum++; bg_sum += al2[i];
                if(al2[i] < 5.0) count_low++;
                else if(al2[i] > 7.2) count_high++;
                else count_ave++;
            }
            if(al2[i] > bg_max) bg_max =al2[i];
            if(al2[i] < bg_min && al2[i] != 0) bg_min = al2[i];
        }
        al2_ave = al2_sum/al2_count;
        al2_ave = (double)Math.round(al2_ave*100)/100;

        for(int i=0;i<30;i++){
            if(bd[i]!=0){
                bd_count++; bd_sum += bd[i]; sum++; bg_sum += bd[i];
                if(bd[i] < 4.4) count_low++;
                else if(bd[i] > 6.1) count_high++;
                else count_ave++;
            }
            if(bd[i] > bg_max) bg_max =bd[i];
            if(bd[i] < bg_min && bd[i] != 0) bg_min = bd[i];
        }
        bd_ave = bd_sum/bd_count;
        bd_ave = (double)Math.round(bd_ave*100)/100;

        for(int i=0;i<30;i++){
            if(ad1[i]!=0){
                ad1_count++; ad1_sum += ad1[i]; sum++; bg_sum += ad1[i];
                if(ad1[i] < 6.7) count_low++;
                else if(ad1[i] > 8.3) count_high++;
                else count_ave++;
            }
            if(ad1[i] > bg_max) bg_max = ad1[i];
            if(ad1[i] < bg_min && ad1[i] != 0) bg_min = ad1[i];
        }
        ad1_ave = ad1_sum/ad1_count;
        ad1_ave = (double)Math.round(ad1_ave*100)/100;

        for(int i=0;i<30;i++){
            if(ad2[i]!=0){
                ad2_count++; ad2_sum += ad2[i]; sum++; bg_sum += ad2[i];
                if(ad2[i] < 5.0) count_low++;
                else if(ad2[i] > 7.2) count_high++;
                else count_ave++;
            }
            if(ad2[i] > bg_max) bg_max = ad2[i];
            if(ad2[i] < bg_min && ad2[i] != 0) bg_min = ad2[i];
        }
        ad2_ave = ad2_sum/ad2_count;
        ad2_ave = (double)Math.round(ad2_ave*100)/100;

        for(int i=0;i<30;i++){
            if(bs[i]!=0){
                bs_count++; bs_sum += bs[i]; sum++; bg_sum += bs[i];
                if(bs[i] < 4.4) count_low++;
                else if(bs[i] > 6.7) count_high++;
                else count_ave++;
            }
            if(bs[i] > bg_max) bg_max = bs[i];
            if(bs[i] < bg_min && bs[i] != 0) bg_min = bs[i];
        }
        bs_ave = bs_sum/bs_count;
        bs_ave = (double)Math.round(bs_ave*100)/100;


        if(sum != 0) bg_ave = bg_sum/sum;

        final View view = inflater.inflate(R.layout.bg_fragment_month,
                container, false);
        String ave = String.format("%.1f",bg_ave);
        String max = Double.toString(bg_max);
        String min = Double.toString(bg_min);
        textView1 = view.findViewById(R.id.bg_ave);
        textView2 = view.findViewById(R.id.bg_high);
        textView3 = view.findViewById(R.id.bg_low);

        textView1.setText(ave);
        textView2.setText(max);
        textView3.setText(min);
        initView(view);
        return view;
    }

    private void initView(View view){

        mScrollView= view.findViewById(R.id.mScro);

        barChart = view.findViewById(R.id.BarChart);
        barChart.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshBarChart();
            }
        });

        pieChart = view.findViewById(R.id.PieChart);
        pieChart.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshPieChart();
            }
        });

        lineChart1 = view.findViewById(R.id.lineChart1);
        lineChart1.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart1();
            }
        });

        lineChart2 = view.findViewById(R.id.lineChart2);
        lineChart2.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart2();
            }
        });

        lineChart3 = view.findViewById(R.id.lineChart3);
        lineChart3.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart3();
            }
        });

        lineChart4 = view.findViewById(R.id.lineChart4);
        lineChart4.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart4();
            }
        });

        lineChart5 = view.findViewById(R.id.lineChart5);
        lineChart5.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart5();
            }
        });

        lineChart6 = view.findViewById(R.id.lineChart6);
        lineChart6.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart6();
            }
        });

        lineChart7 = view.findViewById(R.id.lineChart7);
        lineChart7.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart7();
            }
        });

        lineChart8 = view.findViewById(R.id.lineChart8);
        lineChart8.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart8();
            }
        });

        lineChart9 = view.findViewById(R.id.lineChart9);
        lineChart9.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart9();
            }
        });

        lineChart10 = view.findViewById(R.id.lineChart10);
        lineChart10.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //最好在h5页面加载完毕后再加载数据，防止html的标签还未加载完成，不能正常显示
                refreshLineChart10();
            }
        });
    }

    private void refreshBarChart(){
        Object[] x = new Object[]{
                "早餐前", "早餐后1h", "早餐后2h", "午餐前", "午餐后1h", "午餐后2h", "晚餐前", "晚餐后1h", "晚餐后2h", "睡前"
        };
        Object[] y = new Object[]{
                bb_ave, ab1_ave, ab2_ave, bl_ave, al1_ave, al2_ave, bd_ave, ad1_ave, ad2_ave, bs_ave
        };
        barChart.refreshEchartsWithOption(EchartOptionUtil.getBarChartOptions(x, y));
    }

    private void refreshPieChart(){

        String high = "偏高: " + Integer.toString(count_high)+ " 次";
        String low = "偏低: " + Integer.toString(count_low)+ " 次";
        String ave = "正常: " + Integer.toString(count_ave)+ " 次";
        List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
        HashMap hashMap1 = new HashMap();
        hashMap1.put("value", count_high);
        hashMap1.put("name", high);
        HashMap hashMap2 = new HashMap();
        hashMap2.put("value", count_low);
        hashMap2.put("name", low);
        HashMap hashMap3 = new HashMap();
        hashMap3.put("value", count_ave);
        hashMap3.put("name", ave);
        //pie.data(hashMap,hashMap1,hashMap2);

        data.add(hashMap1);
        data.add(hashMap2);
        data.add(hashMap3);

        pieChart.refreshEchartsWithOption(EchartOptionUtil.getPieChartOptions(data));
    }

    private void refreshLineChart1(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                bb[0], bb[1], bb[2], bb[3], bb[4], bb[5], bb[6], bb[7],bb[8],bb[9],bb[10],bb[11],bb[12],bb[13],bb[14],bb[15],
                bb[16], bb[17], bb[18], bb[19], bb[20], bb[21], bb[22], bb[23],bb[24],bb[25],bb[26],bb[27],bb[28],bb[28],bb[29]
        };
        lineChart1.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }

    private void refreshLineChart2(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                ab1[0], ab1[1], ab1[2], ab1[3], ab1[4], ab1[5], ab1[6], ab1[7],ab1[8],ab1[9],ab1[10],ab1[11],ab1[12],ab1[13],ab1[14],ab1[15],
                ab1[16], ab1[17], ab1[18], ab1[19], ab1[20], ab1[21], ab1[22], ab1[23],ab1[24],ab1[25],ab1[26],ab1[27],ab1[28],ab1[28],ab1[29]
        };
        lineChart2.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }

    private void refreshLineChart3(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                ab2[0], ab2[1], ab2[2], ab2[3], ab2[4], ab2[5], ab2[6], ab2[7],ab2[8],ab2[9],ab2[10],ab2[11],ab2[12],ab2[13],ab2[14],ab2[15],
                ab2[16], ab2[17], ab2[18], ab2[19], ab2[20], ab2[21], ab2[22], ab2[23],ab2[24],ab2[25],ab2[26],ab2[27],ab2[28],ab2[28],ab2[29]
        };
        lineChart3.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }

    private void refreshLineChart4(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                bl[0], bl[1], bl[2], bl[3], bl[4], bl[5], bl[6], bl[7],bl[8],bl[9],bl[10],bl[11],bl[12],bl[13],bl[14],bl[15],
                bl[16], bl[17], bl[18], bl[19], bl[20], bl[21], bl[22], bl[23],bl[24],bl[25],bl[26],bl[27],bl[28],bl[28],bl[29]
        };
        lineChart4.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }

    private void refreshLineChart5(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                al1[0], al1[1], al1[2], al1[3], al1[4], al1[5], al1[6], al1[7],al1[8],al1[9],al1[10],al1[11],al1[12],al1[13],al1[14],al1[15],
                al1[16], al1[17], al1[18], al1[19], al1[20], al1[21], al1[22], al1[23],al1[24],al1[25],al1[26],al1[27],al1[28],al1[28],al1[29]
        };
        lineChart5.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }

    private void refreshLineChart6(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                al2[0], al2[1], al2[2], al2[3], al2[4], al2[5], al2[6], al2[7],al2[8],al2[9],al2[10],al2[11],al2[12],al2[13],al2[14],al2[15],
                al2[16], al2[17], al2[18], al2[19], al2[20], al2[21], al2[22], al2[23],al2[24],al2[25],al2[26],al2[27],al2[28],al2[28],al2[29]
        };
        lineChart6.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }

    private void refreshLineChart7(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                bd[0], bd[1], bd[2], bd[3], bd[4], bd[5], bd[6], bd[7],bd[8],bd[9],bd[10],bd[11],bd[12],bd[13],bd[14],bd[15],
                bd[16], bd[17], bd[18], bd[19], bd[20], bd[21], bd[22], bd[23],bd[24],bd[25],bd[26],bd[27],bd[28],bd[28],bd[29]
        };
        lineChart7.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }

    private void refreshLineChart8(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                ad1[0], ad1[1], ad1[2], ad1[3], ad1[4], ad1[5], ad1[6], ad1[7],ad1[8],ad1[9],ad1[10],ad1[11],ad1[12],ad1[13],ad1[14],ad1[15],
                ad1[16], ad1[17], ad1[18], ad1[19], ad1[20], ad1[21], ad1[22], ad1[23],ad1[24],ad1[25],ad1[26],ad1[27],ad1[28],ad1[28],ad1[29]
        };
        lineChart8.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }

    private void refreshLineChart9(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                ad2[0], ad2[1], al2[2], ad2[3], ad2[4], ad2[5], ad2[6], ad2[7],ad2[8],ad2[9],ad2[10],ad2[11],ad2[12],ad2[13],ad2[14],ad2[15],
                ad2[16], ad2[17], ad2[18], ad2[19], ad2[20], ad2[21], ad2[22], ad2[23],ad2[24],ad2[25],ad2[26],ad2[27],ad2[28],ad2[28],ad2[29]
        };
        lineChart9.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }

    private void refreshLineChart10(){
        Object[] x = new Object[]{
                time.get(0), time.get(1), time.get(2), time.get(3), time.get(4), time.get(5), time.get(6), time.get(7),time.get(8),
                time.get(9), time.get(10), time.get(11), time.get(12), time.get(13), time.get(14), time.get(15), time.get(16),time.get(17),
                time.get(18), time.get(19), time.get(20), time.get(21), time.get(22), time.get(23), time.get(24), time.get(25),time.get(26),
                time.get(27), time.get(28), time.get(29)
        };
        Object[] y = new Object[]{
                bs[0], bs[1], bs[2], bs[3], bs[4], bs[5], bs[6], bs[7],bs[8],bs[9],bs[10],bs[11],bs[12],bs[13],bs[14],bs[15],
                bs[16], bs[17], bs[18], bs[19], bs[20], bs[21], bs[22], bs[23],bs[24],bs[25],bs[26],bs[27],bs[28],bs[28],bs[29]
        };
        lineChart10.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y));
    }
}

